<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var isPowerOfThree = function(n) {
			    while (n !== 0 && n % 3 === 0) {
			        n = Math.floor(n / 3);
			    }
			    return n === 1;
			};
			console.log(isPowerOfThree(3));
		</script>
		
	</body>
</html>
